package day013.homework.p5;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        Collection<String> coll = new ArrayList<>();
        coll.add("JavaEE企业级开发指南");
        coll.add("Oracle高级编程");
        coll.add("MySQL从入门到精通");
        coll.add("Java架构师之路");

        Iterator<String> iter1 = coll.iterator();
        while (iter1.hasNext()) {
            String book = iter1.next();
            System.out.println(book);
        }

        System.out.println("---------------------------------");

        Iterator<String> iter2 = coll.iterator();
        while (iter2.hasNext()) {
            String book = iter2.next();
            if (book.length() < 10) {
                System.out.println(book);
            }
        }

        System.out.println("----------------------------------");

        Iterator<String> iter3 = coll.iterator();
        while (iter3.hasNext()) {
            String book = iter3.next();
            if (book.contains("Java")) {
                System.out.println(book);
            }
        }

        System.out.println("----------------------------------");

        Iterator<String> iter4 = coll.iterator();
        while (iter4.hasNext()) {
            String book = iter4.next();
            if (book.contains("Oracle")) {
                iter4.remove();
            }
        }

//        System.out.println("----------------------------------");
        Iterator<String> iter5 = coll.iterator();
        while (iter5.hasNext()) {
            String book = iter5.next();
            System.out.println(book);
        }

        System.out.println("----------------------------------");
    }
}
